Skip to content

Rust: Update rust-analyzer - #22661

Open
paldepind wants to merge 11 commits into
mainfrom
rust/update-rust-analyzer-sep-23
Open

paldepind wants to merge 11 commits into
mainfrom
rust/update-rust-analyzer-sep-23

Conversation

@paldepind

@paldepind paldepind commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

This PR updates rust-analyzer for the Rust extractor to version 0.0.352.

The biggest change that affects is is a recent change to rust.ungram that introduces a new AST node

AnyAttr =
  Attr | DocComment

as well as DocComment. Pretty much everywhere where Attr where previously used the grammar now specifies AnyAttr. This change is reflected in the dbscheme, QL classes, etc.

DCA

The DCA report is fine. "Lines of code in the database" seems to genuinely have improved by a significant amount. For "Missing call targets" a lot of projects have exactly 12 additional missing targets, but "Calls with a call target" only increases, so this is likely because we're extracting something we didn't extract before (maybe something in a common library).

import codeql.files.FileSystem
import codeql.rust.elements.Abi
import codeql.rust.elements.Addressable
import codeql.rust.elements.AnyAttr
@github-actions github-actions Bot added Rust Pull requests that update Rust code documentation labels Sep 23, 2026
@paldepind
paldepind force-pushed the rust/update-rust-analyzer-sep-23 branch from e417c3b to 3a7f851 Compare September 25, 2026 07:49

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@paldepind
paldepind force-pushed the rust/update-rust-analyzer-sep-23 branch 3 times, most recently from 7ab640b to 7321f99 Compare September 25, 2026 12:05
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 612c2b22-3121-4c83-9656-bb0f4abb2a8a
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a04d83d9-ceea-4109-8ce1-f420585125d4
ra-ap-rustc_lexer requires unicode-ident and unicode-properties to use matching Unicode tables. ra_ap_parser 0.0.352 also requires winnow 0.7.13 to avoid a panic on Unicode following incomplete frontmatter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 612c2b22-3121-4c83-9656-bb0f4abb2a8a
@paldepind
paldepind force-pushed the rust/update-rust-analyzer-sep-23 branch from 7321f99 to c329d70 Compare September 25, 2026 12:12
The new rust-analyzer version fixed a bug related to unicode parsing. As
at test for this, one of the `ra_ap_parser` crate contain a test fixture
with this invalid unicode.

The _current_ Rust extractor naturally inherits the parsing bug present
in the older rust-analyzer dependency that it uses.

When CI does Code Scanning on the _new_ Rust extractor with the _old_
Rust extractor the parsing bug is hit since the beforementioned test
fixture is extracted when extracting the Rust extractor through the
`ra_ap_parser` dependency.

As a temporaty workaroyund, we remove the test fixture from Cargo's
downloaded dependency source before extracting. This avoid the old
extractor failing in CI.

Once the updated extractor is running on CI we should be able to remove
this again.
Regenerate line-count expectations now that documentation comments are extracted as grammar nodes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 612c2b22-3121-4c83-9656-bb0f4abb2a8a
@paldepind
paldepind force-pushed the rust/update-rust-analyzer-sep-23 branch from c329d70 to ffc6ca4 Compare September 25, 2026 12:33
@paldepind
paldepind marked this pull request as ready for review September 28, 2026 07:09
@paldepind
paldepind requested review from a team as code owners September 28, 2026 07:09
Copilot AI balanced review requested due to automatic review settings September 28, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

DocComment loses queryable text, and the declared full downgrade drops documentation comments rather than restoring legacy comment facts.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Updates the Rust extractor to rust-analyzer 0.0.352 and adapts extraction to the new AnyAttr and DocComment AST nodes.

Changes:

  • Updates Rust tooling, dependencies, and generated Bazel metadata.
  • Regenerates schemas, QL libraries, and extractor tests for AnyAttr.
  • Adds migration metadata, diagnostics updates, and CI handling.
File Description
.github/​workflows/​rust-analysis.yml Removes a malformed dependency fixture before analysis.
Cargo.lock, MODULE.bazel, Cargo manifests Update Rust and transitive dependencies.
misc/​bazel/​3rdparty/​tree_sitter_extractors_deps/​** Regenerate vendored Bazel dependency metadata.
rust/​ast-generator/​** Generate AnyAttr extraction via attrs_with_doc.
rust/​extractor/​** Update toolchain and generated extraction code.
rust/​schema/​** Model AnyAttr and DocComment.
rust/​ql/​lib/​codeql/​rust/​** Expose the new AST hierarchy throughout QL.
rust/​ql/​lib/​upgrades/​**, rust/​downgrades/​** Add schema migration metadata.
rust/​ql/​test/​** Regenerate extractor and diagnostic expectations.
rust/​ql/​integration-tests/​conftest.py, rust/​ql/​test/​setup.sh Install Rust 1.98.1 for tests.
rust/​ql/​lib/​change-notes/​** Document the rust-analyzer upgrade.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

fn get_trait_fields(trait_name: &str) -> Vec<FieldInfo> {
match trait_name {
"HasAttrs" => vec![FieldInfo::list("attrs", "Attr")],
"HasAttrs" => vec![FieldInfo::list("attrs", "AnyAttr")],
description: Downgrade rust-analyzer to 0.0.347
compatibility: full

doc_comments.rel: delete

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants